home *** CD-ROM | disk | FTP | other *** search
/ PC-SIG: World of Education / PC-SiG's World of Education.iso / run / 0823 / matrix.doc < prev    next >
Encoding:
Text File  |  1987-01-05  |  30.3 KB  |  784 lines

  1.  
  2.  
  3.  
  4.                     Interactive Matrix Calculator
  5.  
  6.                       Version of 2 January 1987
  7.  
  8.                          Copyright (c) 1987
  9.  
  10.                                  by
  11.  
  12.                            David L. Turner
  13.                      Mountain Home Software Co.
  14.                        13360 N. Mt. Home Road     
  15.                      Cove (Lewiston),Utah  84320
  16.                          Phone (801)258-5164
  17.  
  18.  
  19.  
  20.   Provided as User Supported Software, to be freely copied for 
  21.   noncomercial use.  The author reserves the right to distribute this 
  22.   package or any part thereof, for profit.
  23.  
  24.   If you find this program useful, your voluntary contribution of $25, 
  25.   or whatever you feel the program is worth, will provide updates, 
  26.   further documentation and encouragement for production of similar 
  27.   software.
  28.  
  29.   The program is written and compiled in Microsoft Basic.  It uses 
  30.   double precision arithmetic for all storage and operations.  Due to a 
  31.   limitation of Microsoft Basic, the program operates on only 20 matrix 
  32.   areas, numbered from 1 through 20.  Each matrix may store 150 
  33.   elements, the product of the number of rows with the number of 
  34.   columns.  Since the matrices are stored in contiguous blocks, if every 
  35.   other matrix, say numbers 1,3,5, etc. only, are used, then up to 300 
  36.   elements per matrix may be stored.  Storage of 450 elements per matrix is 
  37.   possible if only areas 1,4,7 etc. are used, 600 elements if only 1,5, 
  38.   etc. are used, etc.  Since the program makes no boundary checks, the 
  39.   151st element of a matrix will be placed into the first position of 
  40.   the next matrix.  
  41.  
  42.   Only one Operation at a time is performed, i.e. only one 
  43.   multiplication, one addition, etc.  Results may be displayed at any 
  44.   time using the Print command.  The storage limit of 20 matrices may be 
  45.   extended by using the disk for additional storage and retrieval.  
  46.  
  47.   Known limitations of the program are those inherent to Microsoft 
  48.   Basic, i.e. limited array storage size, no recognition of path names 
  49.   for files, etc.  The program has been in use in classroom and 
  50.   consulting work for several years, so most of the major bugs have been 
  51.   taken care of.  Registered users will be notified of major updates and 
  52.   new releases.  Problem reports are encouraged as are suggestions for 
  53.   enhancements.
  54.  
  55.   The program is invoked from the MS-DOS prompt by giving the command 
  56.   MATRIX.  This displays the opening screen, which lists the version, 
  57.   the author and the following menu:
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.   Interactive Matrix Calculator Documentation              Page 2
  68.  
  69.  
  70.   Valid Commands are:
  71.      + or A to Add matrices
  72.      C to do Cholesky (Square root) decomposition
  73.      D to Duplicate (copy) from one area to another
  74.      E for Elementary operations loop
  75.      F to Fix a single element
  76.      G to get Part of a matrix (copy part to another)
  77.      I to calculate the Inverse using sweep operator (Gaussian eliminition)
  78.      J to Join two matrices together
  79.      K to Keep or retrive a worksheet to or from disk
  80.      ?, L or H for Help or to List the menu
  81.      * or M to Multiply matrices
  82.      N to print or read a 'nice' matrix
  83.      P to Print a matrix to screen or disk
  84.      Q or X to Quit or Exit
  85.      R to Read in a matrix from keyboard or disk
  86.      - to Subtract matrices
  87.      S to Sweep a matrix
  88.      T to calculate Trace and/or sum of all elements of a matrix
  89.      ' to Transpose a matrix
  90.      Z to change Epsilon or change values < epsilon to 0
  91.  
  92.   READY
  93.  
  94.   Execution of each command is begun immediately after the appropriate 
  95.   letter is touched.  The program prompts the user for additional 
  96.   required input.  A brief alphabetical listing and discussion of each 
  97.   command follows.
  98.  
  99.  
  100.   ADD OR + COMMAND
  101.  
  102.   The program asks for indices for the left, right and answer or 
  103.   destination matrices.  The example below adds Matrix 1 on the left and 
  104.   Matrix 2 on the right, putting the answer into Matrix 3.
  105.  
  106.   READY
  107.   A                                                        
  108.   To Add (left or first) matrix +  (second or right) matrix
  109.   into (destination) matrix, Enter numbers for             
  110.   left, right and destination matrices: 1 2 3
  111.   Matrix  3  = Matrix  1  + Matrix  2
  112.  
  113.  
  114.   CHOLESKY COMMAND
  115.  
  116.   For a nonnegative (positive definite or positive semidefinite) matrix 
  117.   A, the Cholesky or  square root decomposition finds an upper 
  118.   triangular matrix T such that T'T = A.  If a nonsquare matrix (A,B), 
  119.   is input to this routine, then A is still assumed to be a nonnegative 
  120.   matrix.  For such nonsquare matrices, the Cholesky decomposition 
  121.   leaves the T matrix in the first k rows and columns and the product 
  122.   (T'inverse)B in place of the B matrix.  This is a very useful 
  123.   procedure in statistical modeling.  
  124.  
  125.   If the following matrix is in area 3,
  126.  
  127.   Row #  1 :   1 ,   2 ,   3 ,
  128.   Row #  2 :   2 ,   20 ,   26 ,
  129.  
  130.  
  131.  
  132.  
  133.   Interactive Matrix Calculator Documentation              Page 3
  134.  
  135.  
  136.   then the Cholesky command execution is begun by touching the C key at 
  137.   the READY prompt.  The program then asks for the number of the 
  138.   original matrix, the matrix to be "square rooted," and a number for 
  139.   the result.  Again it is a good idea to print the resulting 
  140.   "Choleskied" matrix.  To be certain of the output, calculation and 
  141.   examination of T'T is also recommended.
  142.  
  143.   READY
  144.   C                                                                          
  145.   Cholesky or square root decomposition routine                              
  146.   Enter number of matrix to square root and number of matrix for result:  3 4
  147.   Matrix  4 contains the 'square root' of Matrix 3
  148.  
  149.   This produces the following matrix in area 4:
  150.  
  151.   Row #  1 :   1 ,   2 ,   3 ,
  152.   Row #  2 :   0 ,   4 ,   5 ,
  153.  
  154.  
  155.   DUPLICATE OR COPY COMMAND
  156.  
  157.   Sometimes it is useful to operate on a copy of a matrix rather than 
  158.   the original matrix.  To Duplicate or copy a matrix, touch the D key 
  159.   at the READY prompt.  Then enter the number of the original matrix and 
  160.   the number for the copy or duplicate.
  161.  
  162.   READY
  163.   D
  164.   Matrix Duplication or Copy routine                
  165.   Enter numbers for original and copy matrices:  1 2
  166.   Matrix 2 is a copy or duplicate of Matrix 1
  167.  
  168.  
  169.   ELEMENTARY OPERATIONS COMMAND
  170.  
  171.   This command lets the user perform elementary row operations such as 
  172.   interchanging 2 rows, multiplying or dividing a row by a constant or 
  173.   adding a multiple of a row to another row.   
  174.  
  175.   If a matrix A is augmented by an appropriate sized identity, and then 
  176.   elementary row operations are performed on the augmented matrix (A,I) 
  177.   until the matrix looks like (I,B), then B will be the inverse of A.  
  178.   If the original A matrix cannot be reduced to an identity, coming as 
  179.   close as possible will make B a generalized inverse of A.
  180.  
  181.   For the example below, the matrix (1 2/2 5) is augmented with a 2 x 2 
  182.   identity matrix and this 2 x 4 matrix is then loaded into matrix area 
  183.   1.  To start the Elemenrary row operations, press the E key at the 
  184.   READY prompt and then follow the instructions.
  185.  
  186.   For this simple example, the first row is multiplied by -2 and added 
  187.   to the second row.  After printing this intermediate result, it is 
  188.   easy to see that the second row must be multiplied by -2 and added to 
  189.   the first row.  This makes an identity matrix where the A matrix 
  190.   started and consequently contains the inverse of A where the identity 
  191.   started.  This inverse may then be extracted from this augmented 
  192.   matrix using the Get command.
  193.  
  194.   READY
  195.   E
  196.  
  197.  
  198.  
  199.   Interactive Matrix Calculator Documentation              Page 4
  200.  
  201.  
  202.   Routine to do elementary row operations
  203.   Enter number of matrix to work on:  ? 1
  204.  
  205.      C followed by numbers of rows to interchange
  206.  
  207.      Enter M or * (D or /) followed by first row#, scalar, second row#
  208.      to Multiply(Divide) first row by scalar and add to second row
  209.  
  210.      If second row# is omitted, row will be multiplied by scalar
  211.  
  212.      P will print the matrix
  213.  
  214.      L or H to print menu (list) of elementary commands
  215.  
  216.      <CR> will return to main menu (terminate elementary operations)
  217.  
  218.   Enter operator:  M 1 -2 2
  219.   Row # 1  has been multiplied by -2  and added to row # 2
  220.  
  221.   Enter operator:  P
  222.  
  223.   Row #  1 :   1 ,   2 ,   1 ,   0 ,
  224.   Row #  2 :   0 ,   1 ,  -2 ,   1 ,
  225.  
  226.   Enter operator:  M 2 -2 1
  227.   Row # 2  has been multiplied by -2  and added to row # 1
  228.  
  229.   Enter operator:  P
  230.  
  231.   Row #  1 :   1 ,   0 ,   5 ,  -2 ,
  232.   Row #  2 :   0 ,   1 ,  -2 ,   1 ,
  233.   Enter operator: <cr>
  234.  
  235.  
  236.   FIX COMMAND
  237.  
  238.   Since few typists or data entry personnel are perfect, a command is 
  239.   provided to fix a single element in any of the matrices.  To Fix a 
  240.   matrix, touch the F key at the READY prompt and follow the 
  241.   instructions.  The example below makes the element in row 1 and column 
  242.   3 of matrix 1 equal to 33.  It is a good idea to print the matrix 
  243.   after changing an element to confirm that the change has taken place.
  244.  
  245.   READY
  246.   F
  247.   Matrix Fixing routine                             
  248.   Enter matrix number, row no. and column no.       
  249.   of element to fix and the correct value:  1 1 3 33
  250.   The element in row  1 and column  1 of Matrix  3 has been changed to 33
  251.  
  252.  
  253.   GET COMMAND
  254.  
  255.   Sometimes a matrix must be decomposed into some smaller pieces.  This 
  256.   may be done with the Get command.  Columns and rows from one matrix 
  257.   are copied into a second matrix.  If matrix 3 contains the product 
  258.   (X,Y)'(X,Y), then Rows 1 and 2 and columns 1 and 2 contain the X'X 
  259.   matrix.  Rows 1 and 2 of column 3 contain X'Y.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.   Interactive Matrix Calculator Documentation              Page 5
  266.  
  267.  
  268.   To start the Get command, just touch the G key at the READY prompt and 
  269.   follow the instructions.
  270.   READY
  271.   G
  272.   Get part of a matrix                      
  273.   Enter number of original and new matrices:  3 5
  274.  
  275.   Enter the number of rows for the new matrix:  ? 2
  276.  
  277.   Now enter  2  indices for the rows to be selected from old matrix
  278.   to be put into the new matrix  1 2
  279.  
  280.   Now enter the number of columns for the new matrix  ? 1
  281.  
  282.   Now enter   1  indices for columns to be selected from the old matrix
  283.   to be put into the new matrix  3
  284.   Matrix  5 contains parts of Matrix 3
  285.  
  286.   READY
  287.   P
  288.   Enter number of matrix to print:
  289.   or enter file name to write matrix to a disk file: 5
  290.  
  291.   Row #  1 :   6 ,   46 ,
  292.   Row #  2 :   46 ,   462 ,
  293.  
  294.  
  295.   INVERSE COMMAND
  296.  
  297.   Gaussian elimination or pivoting is the only explicit inverse routine 
  298.   provided in this package.  Some very elementary checks are built in to 
  299.   prevent division by zero or by a number "close" to zero.  The validity 
  300.   of any inverse computed by this procedure should be checked by seeing 
  301.   if the product of the orignial matrix and the supposed inverse is 
  302.   "close" to an identity matrix.
  303.  
  304.   The X'X matrix Gotten in the Get example is inverted.  The procedure 
  305.   is invoked by touching the I key at the READY prompt and then giving 
  306.   the number of the matrix to invert and the number of the matrix for 
  307.   storing the result.  The actual value of the pivoting element is 
  308.   printed. The matrix must be swept or pivoted on each diagonal element.  
  309.   In the example below, the answer is checked by multiplication.  Note 
  310.   that this product matrix is "close" to an identity matrix.
  311.  
  312.   READY
  313.   I
  314.   Inversion using Sweep operator (Gaussian elimination)
  315.   Enter index of matrix to invert and index for result:  4 6
  316.   Sweeping element # 2   With diagonal value= 462
  317.   Sweeping element # 1   With diagonal value= 1.4199134199134
  318.   Matrix  6 = (Matrix  4)inverse
  319.  
  320.   READY
  321.   M
  322.   To Multiply (left or first) matrix * (second or right) matrix
  323.   into (destination) matrix, enter numbers for                 
  324.   left, right and destination matrices                         
  325.   Or to multiply a matrix by a scalar enter M (or D to divide) 
  326.   followed by matrix number and scalar: 4 6 7
  327.   Matrix  7  = Matrix  4  * Matrix  6
  328.  
  329.  
  330.  
  331.   Interactive Matrix Calculator Documentation              Page 6
  332.  
  333.  
  334.   READY
  335.   P
  336.   Matrix output routine                              
  337.   Enter number of matrix to display or               
  338.   enter a file name to write matrix to a disk file: 7
  339.  
  340.   Row #  1 :   .9999999999999999 ,  -6.938893903907228D-18 ,
  341.   Row #  2 :  -8.881784197001252D-16 ,   1 ,
  342.  
  343.  
  344.   JOIN COMMAND
  345.  
  346.   The Join command is used to augment or put together two matrices.  To 
  347.   Join 2 matrices together, touch the J key at the READY prompt and 
  348.   follow the instructions.  Again it is a good idea to print the 
  349.   resulting joined or augmented matrix.   For vertical augmentation, 
  350.   work with transposes and then transpose the final augmented matrix.
  351.  
  352.   READY
  353.   J
  354.   Matrix Joining or augmentation routine                     
  355.   Enter numbers for left, right and augmented matrices: 2 2 3
  356.   Matrix  3 = (Matrix 2, Matrix 2)
  357.  
  358.  
  359.   KEEP AND RETRIEVE COMMANDS
  360.  
  361.   To save or retrieve all the matrices for a particular worksheet, the 
  362.   Keep command is used.  It dumps or retrieves all the matrices to or 
  363.   from a file, allowing the user to save all of the current matrices or 
  364.   to retrieve all of the matrices used in a previously saved worksheet.
  365.  
  366.   Touching the K key at the READY prompt causes the program to prompt 
  367.   the user for more information.  To save the current worksheet type S 
  368.   followed by a file name.  To retrieve a previously saved worksheet, 
  369.   type R followed by the name of the file to be retrieved.  
  370.  
  371.   The Save operation creates a file whose first 2 records describe what 
  372.   the file is.  The next record tells the overall size of the worksheet,  
  373.   the number of matrices available and the number of elements for each 
  374.   one.  Then comes information about each matrix:  the matrix number, 
  375.   the number of rows and the number of columns followed by the elements 
  376.   of the matrix in rowwise order.
  377.  
  378.   When retrieving a saved worksheet, the program lists the matrix number 
  379.   and size for each matrix as it is retrieved.  An example of both 
  380.   saving and the later retrieval of a worksheet is given below.
  381.  
  382.   READY
  383.   K
  384.   Worksheet Save/Retrieve routine
  385.   Enter S to Save a worksheet
  386.         R to Retrieve or Reload a worksheet: S
  387.   Enter name of file to be Saved or Retrieved: try.sav
  388.   Saving the matrix worksheet into a file named try.sav
  389.    2  x  2  Matrix  1  in the worksheet stored in file try.sav
  390.    2  x  2  Matrix  2  in the worksheet stored in file try.sav
  391.    2  x  4  Matrix  3  in the worksheet stored in file try.sav
  392.  
  393.  
  394.  
  395.  
  396.  
  397.   Interactive Matrix Calculator Documentation              Page 7
  398.  
  399.  
  400.   READY
  401.   K
  402.   Worksheet Save/Retrieve routine
  403.   Enter S to Save a worksheet
  404.         R to Retrieve or Reload a worksheet: R
  405.   Enter name of file to be Saved or Retrieved: try.sav
  406.   Retrieving a worksheet from the file named try.sav
  407.   Beginning to load a matrix into area # 1
  408.   Matrix area number  1  has been successfully loaded with a  2  x  2  matrix
  409.  
  410.   Beginning to load a matrix into area # 2
  411.   Matrix area number  2  has been successfully loaded with a  2  x  2  matrix
  412.  
  413.   Beginning to load a matrix into area # 3
  414.   Matrix area number  3  has been successfully loaded with a  2  x  4  matrix
  415.  
  416.  
  417.   ?, HELP or LIST COMMAND
  418.  
  419.   Very limited help is provided in this program, i.e. the list of valid 
  420.   commands is printed whenever a ?,H or L key is touched at the READY 
  421.   prompt.
  422.  
  423.  
  424.   MULTIPLY COMMAND
  425.  
  426.   Two matrices may be multiplied together only if they are conformable for 
  427.   multiplication.  This means that the number of columns in the left or 
  428.   first matrix must be the same as the number of rows in the right or 
  429.   second matrix.  The program does not make any checks for conformability, 
  430.   so the user must be careful, and printing of each of the component 
  431.   matrices and the product matrix is recommended.  As an example, the 
  432.   product M2*M1 is computed below and placed into matrix area number 3.
  433.  
  434.   READY
  435.   M
  436.   To Multiply (left or first) matrix * (second or right) matrix
  437.   into (destination) matrix, enter numbers for                 
  438.   left, right and destination matrices                         
  439.   Or to multiply a matrix by a scalar enter M (or D to divide) 
  440.   followed by matrix number and scalar: 2 1 3                  
  441.   Matrix  3  = Matrix  2  * Matrix  1
  442.  
  443.   This command may also be used for performing scalar multiplication or 
  444.   division where each element of a matrix is to be multplied or divided 
  445.   by a scalar.
  446.  
  447.   READY                                                       
  448.   M
  449.   To Multiply (left or first) matrix * (second or right) matrix
  450.   into (destination) matrix, enter numbers for                
  451.   left, right and destination matrices                        
  452.   Or to multiply a matrix by a scalar enter M (or D to divide)
  453.   followed by matrix number and scalar: M 1 3                 
  454.   Every element in matrix number  1  has been multiplied by  3
  455.  
  456.   READY                                                       
  457.   M
  458.   To Multiply (left or first) matrix * (second or right) matrix
  459.   into (destination) matrix, enter numbers for                
  460.  
  461.  
  462.  
  463.   Interactive Matrix Calculator Documentation              Page 8
  464.  
  465.  
  466.   left, right and destination matrices                        
  467.   Or to multiply a matrix by a scalar enter M (or D to divide)
  468.   followed by matrix number and scalar: D 1 2
  469.   Every element in matrix number  1  has been multiplied by  .5
  470.  
  471.  
  472.   NICE PRINT/READ COMMAND
  473.  
  474.   Microsoft Basic has very primitive output formatting capacities, but 
  475.   some nicer formatting is possible.  This command functions just about 
  476.   like the Print command.  To print a matrix in a "nice" format, touch 
  477.   the N key, then the P key and then specify the matrix to print.  The 
  478.   matrix is then printed in scientific notation.  For example, 
  479.   -.7012195122D-01 translates as -.7012195122 times 10 to the -1 power, 
  480.   or -0.07012195122 for the final answer.
  481.  
  482.   READY
  483.   N
  484.   For a 'nice' printout enter 'P'                                 
  485.   To input a 'nice' (i.e. rectangular) matrix, enter 'R': P
  486.   Matrix output routine                              
  487.   Enter number of matrix to display or               
  488.   enter a file name to write matrix to a disk file: 4
  489.  
  490.   Row #  1 :  0.7042682927D+00,  -.7012195122D-01,  0.4975609756D+01,
  491.   Row #  2 :  -.7012195122D-01,  0.9146341463D-02,  0.8292682927D+00,
  492.   Row #  3 :  -.4975609756D+01,  -.8292682927D+00,  0.1214634146D+02,
  493.  
  494.   The Nice command may also be used to read in rectangular matrices or 
  495.   data from a previously prepared disk file.  For example, if the matrix 
  496.   (1 2 3/4 5 6) is stored in a file named TRY.IT which contains 2 
  497.   records, one for each row, then this file may be read into a matrix 
  498.   area using the  Nice Read command.  Note that the 2 values for number 
  499.   of rows and number of columns must be separated by a comma for this 
  500.   routine.
  501.  
  502.   READY
  503.   N
  504.   For a 'nice' printout enter 'P'                              
  505.   To input a 'nice' (i.e. square) matrix, enter 'R': R
  506.   Enter name of previously saved file to read from disk: try.it
  507.   Reading a matrix from a previously saved file try.it         
  508.   Enter the number of the area to read matrix into ? 1         
  509.   Enter number of rows and columns for the matrix: ? 2 3       
  510.   ?Redo from start                                             
  511.   ? 2,3                                                        
  512.    2 x 3 matrix from file try.it read into Matrix 1
  513.                                                                
  514.   READY                                                        
  515.   P
  516.   Matrix output routine                                        
  517.   Enter number of matrix to display or                         
  518.   enter a file name to write matrix to a disk file: 2          
  519.                                                                
  520.   Row #  1 :   1 ,   2 ,   3 ,                                 
  521.   Row #  2 :   4 ,   5 ,   6 ,                                 
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.   Interactive Matrix Calculator Documentation              Page 9
  530.  
  531.  
  532.   PRINT COMMAND
  533.  
  534.   To see the results of any command, the Print command must be used.  
  535.   The program prompts for and prints only one matrix at a time.  Any 
  536.   matrix may also be printed to disk, expanding the storage capacity of 
  537.   the program.  An example of disk storage for an individual matrix is 
  538.   provided below.  The example below is started by touching the P key at 
  539.   the READY prompt and then entering 2 as the number of the matrix to be 
  540.   printed.
  541.  
  542.   READY
  543.   P
  544.   Matrix output routine                              
  545.   Enter number of matrix to display or               
  546.   enter a file name to write matrix to a disk file: 1
  547.  
  548.  
  549.   PRINT TO DISK COMMAND
  550.  
  551.   While only 20 matrices are available for internal storage, matrices 
  552.   may be written to disk files, one file per matrix.  To create a disk 
  553.   file for any matrix, simply touch the P key at the READY prompt and 
  554.   then enter a file name rather than a matrix number.  The program will 
  555.   then prompt for the number of the matrix to be written to the disk 
  556.   file.  For example, to create a file which contains the matrix stored 
  557.   in area number 1, give the file name EXAMPLE.MAT when prompted for the 
  558.   matrix number.
  559.  
  560.   READY
  561.   P
  562.   Matrix output routine                                        
  563.   Enter number of matrix to display or                         
  564.   enter a file name to write matrix to a disk file: example.mat
  565.   Number of Matrix to write to disk: ? 1                       
  566.   Matrix  1 written to the file example.mat
  567.  
  568.  
  569.   QUIT, EXIT OR STOP COMMAND
  570.  
  571.   Although a control-C or control-Break command will kill the program, 
  572.   the Q or X command will cause a "graceful" exit from the program.  
  573.   Touching the Q or X key at the READY prompt causes the program to 
  574.   terminate.
  575.  
  576.  
  577.   READ COMMAND
  578.  
  579.   Before any operations may be performed, something must be read into 
  580.   the matrix worksheet to operate on.  To read a matrix in, the Read 
  581.   command is used.  The program then asks for the number of the matrix 
  582.   to read data into, and then the number of rows and columns to be read 
  583.   in.  The program then prompts for the entries for each row.  The 
  584.   numbers for each row must then be entered separated by commas or 
  585.   blanks.
  586.  
  587.   For example, to read a 2 row by 3 column matrix into area 1, start by 
  588.   touching the R key at the READY prompt, and then following the 
  589.   instructions.  The first line indicates that the matrix is to be read 
  590.   into area 1 and that it will contain 2 rows and 3 columns.  The 
  591.   elements for the first row are then entered, followed by the elements 
  592.   for the second row.
  593.  
  594.  
  595.   Interactive Matrix Calculator Documentation              Page 10
  596.  
  597.  
  598.  
  599.  
  600.   READY
  601.   R
  602.   Matrix Read or Input Routine                              
  603.   Enter matrix number, no. rows and no. columns or enter a  
  604.   file name to read a previously saved file from disk: 1 2 3
  605.   Input row #  1 :  1 2,3
  606.   1 2,3
  607.   Input row #  2 :  4,5,1
  608.   4,5,1
  609.  
  610.  
  611.   READ FROM DISK COMMAND
  612.  
  613.   To read a matrix back into a matrix area, give the file name when 
  614.   prompted for a matrix number.  The example below reloads the matrix 
  615.   saved previously in the file EXAMPLE.MAT.
  616.  
  617.   READY                                                             
  618.   R
  619.   Matrix Read or Input Routine                                      
  620.   Enter matrix number, no. rows and no. columns or enter a          
  621.   Enter name of previously saved file to read from disk: example.mat
  622.   Reading a matrix from a previously saved file example.mat         
  623.   Enter the number of the area to read matrix into ? 2              
  624.    2 x 4 matrix read from the file example.mat into Matrix 2
  625.  
  626.  
  627.   SUBTRACT OR - COMMAND
  628.  
  629.   The Subtract command works just like the addition command except that 
  630.   the right or second matrix is subtracted from the left or first 
  631.   matrix.  For example,
  632.  
  633.   READY
  634.   -                                                             
  635.   To Subtract (left or first) matrix -  (second or right) matrix
  636.   into (destination) matrix, Enter numbers for                  
  637.   left, right and destination matrices: 1 2 3                   
  638.   Matrix 3 = Matrix 1 - Matrix 2
  639.  
  640.  
  641.   SWEEP COMMAND
  642.  
  643.   The sweep command may be used in finding inverses of "nice" matrices.  
  644.   It performs Gaussian elimination one step at a time.  It is a very 
  645.   convenient method of performing multiple regression analysis 
  646.   computations especially when any variable selection is to be done.  
  647.   The matrix listed below contains the product (X,Y)'(X,Y) = X'X  X'Y
  648.                                                              Y'X  Y'Y
  649.   The X matrix contains the X or independent variables to be used in 
  650.   predicting the Y variable.  After sweeping one or more variables into 
  651.   the equation, the column which originally contained X'Y will contain 
  652.   the regression coefficients for those variables in the equation.  The 
  653.   single element corresponding to the Y'Y element in the initial or 
  654.   original matrix will contain the error sum of squares for the model 
  655.   containing the swept variables.  
  656.  
  657.   One nice feature of the sweep operator is that it is reversible. This 
  658.   means that if a variable is swept twice, the second sweep removes the 
  659.  
  660.  
  661.   Interactive Matrix Calculator Documentation              Page 11
  662.  
  663.  
  664.   variable from the equation.  This procedure is widely used in stepwise 
  665.   regression programs.  
  666.  
  667.   Generally the first column and row corresponds to an X variable which 
  668.   is equal to 1 for each observation to put the intercept into the 
  669.   equation.  The second, third, etc. columns correspond to the first, 
  670.   second, etc. variables available for the equation.  The last row and 
  671.   column corresponds to the Y variables.
  672.  
  673.   In the example below, the intercept is first "swept" into a 1 variable 
  674.   equation which also has an intercept.  This gives corrected sums of 
  675.   squares and crossproducts for the second and third columns and rows of 
  676.   this matrix.  The second sweep operation gives the (X'X) inverse, the 
  677.   vector of regression coefficients and the error sum of squares.  The 
  678.   initial, unswept matrix is
  679.  
  680.   Row #  1 :   6 ,   46 ,   68 ,
  681.   Row #  2 :   46 ,   462 ,   612 ,
  682.   Row #  3 :   68 ,   612 ,   858 ,
  683.  
  684.   READY
  685.   S
  686.   Sweep Operator                               
  687.   Enter matrix and element number to sweep: 4 1
  688.   Matrix  4 has been swept on element  1
  689.  
  690.   READY
  691.   S
  692.   Sweep Operator                               
  693.   Enter matrix and element number to sweep: 4 2
  694.   Matrix  4 has been swept on element  2
  695.  
  696.   READY
  697.   P
  698.   Matrix output routine                            
  699.   Enter number of matrix to display or             
  700.   enter a file name to write matrix to a disk file: 4
  701.  
  702.   Row #  1 :   .1666666666666667 ,   7.666666666666667 ,   11.33333333333333 ,
  703.   Row #  2 :  -7.666666666666667 ,   109.3333333333333 ,   90.66666666666667 ,
  704.   Row #  3 :  -11.33333333333333 ,   90.66666666666667 ,   87.33333333333333 ,
  705.  
  706.  
  707.   TRACE COMMAND
  708.  
  709.   Sometimes the sum of the diagonal elements, the trace of a matrix, is 
  710.   needed.  This is done with the Trace Command which is started by 
  711.   touching the T key at the READY prompt.  This causes the program to 
  712.   prompt the user for a matrix number.  The sum of all the elements and 
  713.   the sum of the diagonal elements is then computed and printed.
  714.  
  715.   READY
  716.   T
  717.   Matrix Trace and sum routine                          
  718.   Enter number of matrix whose elements are to be summed
  719.   or whose trace is to be found if matrix is square: ? 2
  720.   Sum of all elements in matrix area # 2  is  2         
  721.   Trace of matrix area # 2  is  2                       
  722.  
  723.  
  724.  
  725.  
  726.  
  727.   Interactive Matrix Calculator Documentation              Page 12
  728.  
  729.  
  730.   TRANSPOSE COMMAND
  731.  
  732.   The Transpose command interchanges rows and columns, for example 
  733.   changing the ith row into the ith column.  If a(ij) represents the 
  734.   element in the ith row and jth column of the original matrix A, then it 
  735.   will become the element in the jth row and ith column of A', the 
  736.   transpose.  If the original matrix has m rows and n columns, then the 
  737.   transpose will have n rows and m columns.  Again, it is a good idea to 
  738.   print the transposed matrix.  Execution begins by touching the ' key 
  739.   and then entering the numbers for the origninal and transpose 
  740.   matrices.
  741.  
  742.   READY
  743.   '                                                                     
  744.   Transpose routine                                                     
  745.   Enter number of matrix to transpose and matrix number for result:  1 2
  746.   Matrix  2 = Matrix  1'
  747.  
  748.  
  749.   FUZZ COMMAND
  750.  
  751.   Sometimes values that should be zero turn out "close" to zero.  For 
  752.   example, -8.88 times 10 to the minus 16 is "close" to zero.  The Fuzz 
  753.   routine goes through and compares each element of a matrix with an 
  754.   "Epsilon" value, changing those which are smaller in absolute value 
  755.   than Epsilon to zero.  The first part of the Fuzz command allows the 
  756.   user to change the value of Epsilon.  The second part allows a 
  757.   particular matrix to be "defuzzed."
  758.  
  759.   The product of a matrix with its diagonal should be an identity 
  760.   matrix, but often the off-diagonal elements are close but not quite 
  761.   equal to zero.  Touching the "Z" key at the READY prompt starts the 
  762.   Fuzz procedure.  For the example below, a matrix is defuzzed and then 
  763.   printed.  Note that the first element should be 1, but is instead 
  764.   "close" to one.  The fuzz routine changes only values that are "close" 
  765.   to zero. 
  766.  
  767.   READY
  768.   Z
  769.   Matrix defuZzing routine                                                 
  770.   Epsilon is currently  1.000000013351432D-10                              
  771.   Enter a new value to change, or hit <CR> to leave:                       
  772.                                                                            
  773.   To defuZz or convert absolute values <  1.000000013351432D-10  to zeroes,
  774.   Enter matrix area number.  <CR> Otherwise: 2                             
  775.                                                                            
  776.   Values in matrix area # 2  which were less than                          
  777.    1.000000013351432D-10  have been changed to zeroes                      
  778.   p                                                  
  779.   Matrix output routine                              
  780.   Enter number of matrix to display or               
  781.   enter a file name to write matrix to a disk file: 2
  782.  
  783.   Row #  1 :   .9999999999999999 ,   0 ,
  784.   Row #  2 :   0 ,   1 ,